package cn.ppwx.crm.modules.sys.service;

import java.util.List;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.ppwx.crm.modules.sys.dao.UserMapper;
import cn.ppwx.crm.modules.sys.entity.User;


@Service
public class UserService {
	
	
	@Autowired
	private UserMapper  userMapper;
	
	@Autowired
	private  RuntimeService runtimeService;
	
	@Autowired
	private  TaskService taskService;
	

	
	public List<Task>  queryTodoTask(User user){
		
		List<Task> tasks =taskService.createTaskQuery().taskAssignee(user.getUserId().toString()+"."+user.getUserName().toString()).orderByTaskCreateTime().desc().list();
		return tasks;
	}
	
	
	public User  getUserById(long userId){
		return userMapper.selectByPrimaryKey(userId);
	}
	

	public long  getUserMangerIdById(long userId,String aggree){
		
		if("false".equals(aggree)){
			return 0;
		}
		
		return userMapper.selectByPrimaryKey(userId).getManagerId();
	}
	

}
